/**
 * This file is Copyright © 2008 Software Craftsmen Limited. All Rights Reserved.
 */
package com.softwarecraftsmen.cachecontrol.keys;

import static com.softwarecraftsmen.cachecontrol.SafeStringFormatter.format;
import org.jetbrains.annotations.NotNull;

public class SimpleKey<V> extends AbstractKey<V>
{
	@NotNull private final Object key;

	public SimpleKey(@NotNull final Object key)
	{
		this.key = key;
	}

	public @NotNull String toString()
	{
		return format("SimpleKey(%1$s)", key);
	}

	public int hash()
	{
		return key.hashCode();
	}

	public boolean exactlyMatches(@NotNull final Key<V> key)
	{
		return this.getClass().equals(key.getClass()) && key.equals(((SimpleKey) key).key);
	}
}
